/**
 * @description: webapi任务队列
 * @version: 0.0.1
 * @author: xiech
 * @Date: 2023-06-05 10:12:28
 */

import { Processor, IProcessor, Context } from '@midwayjs/bull';
import { Inject } from '@midwayjs/core';
import { ScheduleTasksWebapiService } from "../service/schedule.tasks.webapi.service"

@Processor('WebApiTask',{
  repeat: {
    cron: '0 0/5 * * * ?'
  }
})
export class WebApiTaskProcessor implements IProcessor {

  @Inject()
  ctx: Context;

  @Inject()
  ScheduleTasksWebapiService: ScheduleTasksWebapiService;

  async execute(params: any) {
    return new Promise<void>(async resolve => {
      await this.ScheduleTasksWebapiService.webApiQueueTasks();
      resolve();
    })
  }
}
